package com.zhongshan.ga.mybatis.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zhongshan.ga.mybatis.bean.PeopleInfoBean;


/**
 * 用户信息数据访问接口
 * @author kakaxi
 *
 */
public interface IPeopleInfoDao {
	
	/**
	 * 添加用户信息
	 * @param peopleInfo 用户信息类
	 * @return
	 */
	@Insert("INSERT INTO peopleInfo (PeopleSystemCode, NAME, Sex, Age, Address, PhoneNumber,"
			+ " Birthday, SecondPhoneNum, QQ, WeChat, Weibo, Email, IsVip, InnermostWords,"
			+ " NickName) VALUES(#{peopleSystemCode}, #{name}, #{sex}, #{age}, #{address}, #{phoneNumber}, "
			+ " #{birthday}, #{secondPhoneNum}, #{QQ}, #{weChat}, #{weibo}, #{email}, #{isVip}, "
			+ "#{innermostWords}, #{nickName})")
	public int addPeopleInfo(PeopleInfoBean peopleInfo);
	
	/**
	 * 更新用户信息
	 * @param peopleInfo 
	 * @return
	 */
	@Update("UPDATE peopleInfo SET NAME=#{name}, Sex=#{sex}, Age=#{sex}, Address=#{address}, "
			+ "PhoneNumber=#{phoneNumber}, Birthday=#{birthday}, SecondPhoneNum=#{secondPhoneNum},"
			+ " Email=#{email}, IsVip=#{isVip}, InnermostWords=#{innermostWords}, "
			+ "NickName=#{nickName} where PeopleSystemCode=#{peopleSystemCode}")
	public int updatePeopleInfo(PeopleInfoBean peopleInfo);
	
	/**
	 * 获取所有用户信息
	 * @return
	 */
	@Select("select * from peopleInfo")
	public List<PeopleInfoBean> getAllPeopleInfo();
	
	/**
	 * 根据用户编码获取用户信息
	 * @param peopleSystemCode 用户编码
	 * @return
	 */
	@Select("select * from peopleInfo where PeopleSystemCode=#{peopleSystemCode}")
	public PeopleInfoBean getPeopleInfoByCode(String peopleSystemCode);
	
	/**
	 * 根据用户qq获取用户信息
	 * @param qq
	 * @return
	 */
	@Select("select * from peopleInfo where QQ=#{qq}")
	public PeopleInfoBean getPeopleInfoByQQ(String qq);
	
	/**
	 * 根据用户微博获取用户信息
	 * @param weibo
	 * @return
	 */
	@Select("select * from peopleInfo where Weibo=#{weibo}")
	public PeopleInfoBean getPeopleInfoByWeibo(String weibo);
	
	/**
	 * 根据用户微信获取用户信息
	 * @param wechat
	 * @return
	 */
	@Select("select * from peopleInfo where WeChat=#{weChat}")
	public PeopleInfoBean getPeopleInfoByWechat(String wechat);
	
	/**
	 * 更新个人信息数据接口
	 * @param peopleInfo
	 * @return
	 */
	@Update("UPDATE peopleinfo SET PhoneNumber = #{phoneNumber}, sex = #{sex}, nickName = #{nickName}, InnermostWords = #{innermostWords}, Email = #{email} WHERE PeopleSystemCode = #{peopleSystemCode} ")
	public int updatePrivateInfo(PeopleInfoBean peopleInfo);

}
